// app.js
App({
  globalData: {
    userInfo: null,
    phone: null,
    serverDate: null,
  },
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
    //开启云函数使用
    wx.cloud.init({
      env:'sm-arete-5g1a0i6r9304cc90',
      traceUser: true,
    })
    serverDate: this.getserverDate()
    this.globalData.phone=wx.getStorageSync('phone')
  },
  getserverDate: function (callback) {
    wx.cloud.callFunction({
      name: 'get-time',
      success: (res) => {
        this.globalData.serverDate = res.result
        if(callback)callback(res.result);//执行回调
      }
    })
  }
})